package com.run.serial;

import android.util.Log;

public class SerialRxData {
    private static SerialRxData serialData;

    private RxDataCallBack rxDataCallBack = null;

    private SerialRxData() {

    }

    protected static SerialRxData getInstance() {
        if (serialData == null) {
            synchronized (SerialRxData.class) {
                if (serialData == null) {
                    serialData = new SerialRxData();
                }
            }
        }
        return serialData;
    }

    protected void setRxDataCallBack(RxDataCallBack callBack) {
        rxDataCallBack = callBack;
    }

    protected synchronized void rxDataPackage(String origin, byte[] data, int len) {
        /*Log.d("read", ">>-  " + ConvertData.byteArrayToHexString(data, len) + "  " + (data[0] & 0xFF)
                + "  " + SerialCommand.EXC_SUCCEED + "  " + SerialCommand.PACK_FRAME_HEADER);*/
        if (rxDataCallBack == null) {
            return;
        }
        rxDataCallBack.onSucceed(origin, data, len);
    }

}
